<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 在编程语言中 一切皆对象 所谓js的对象其实是一组无需的属性的组合
        // class 其实可以看作一个语法糖
        // function Game(name) {
        //     this.name = name
        // }
        // Game.prototype.play = function() {
        //     console.log('欢迎进入' + this.name);
        // }

        // let game = new Game('王者荣耀')
        // console.log(game);


        // class 类中的函数都是直接挂载在类的原型上的
        class Game {
            constructor(name) {
                this.name = name
                this.fn = function() {
                    console.log('这是一个函数');
                }
            }
            play() {
                console.log('欢迎进入' + this.name);
            }
        }
        // console.log(Game.prototype);
        // let game = new Game('王者荣耀')
        // console.log(game);
        // game.play()
        Game.prototype.run = function() {
            console.log('游戏启动了');
        }
        let game = new Game('王者荣耀')
        console.log(game);
    </script>
</body>

</html>